package com.atguigu.serviceoss.controller;

import com.atguigu.commonutils.R;
import com.atguigu.serviceoss.service.OssService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author JY
 * @create 2021-01-17 23:35
 */
@Api(description="阿里云文件管理")
@RestController
@RequestMapping("/oss/file")
//@CrossOrigin
public class OssController {
    @Autowired
    private OssService ossService;

    //文件上传
    @PostMapping("upload")
    public R upload(MultipartFile file){
        String avatarUrl = ossService.upload(file);
        return R.ok().data("avatar",avatarUrl);
    }
}
